library MovespeedCommand initializer init requires LegacySystem

	private function MovespeedCommand takes nothing returns nothing
		local player p = GetTriggerPlayer()
		local integer i = 1
		loop
			exitwhen i>udg_InitialPlayers
			if GetWidgetLife(udg_Hero[udg_Sorted[i]])>0.405 then
				call DisplayTimedTextToPlayer( p, 0, 0, 15.0, udg_Pcolors[udg_Sorted[i]] + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + "|r - " + I2S(R2I(GetUnitMoveSpeed(udg_Hero[udg_Sorted[i]]))) + "ms" )
			elseif GetWidgetLife(udg_Pet[udg_Sorted[i]])>0.405 then
				call DisplayTimedTextToPlayer( p, 0, 0, 15.0, udg_Pcolors[udg_Sorted[i]] + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + "|r's pet - " + I2S(R2I(GetUnitMoveSpeed(udg_Pet[udg_Sorted[i]]))) + "ms" )
			endif
			set i=i+1
		endloop
		call DisplayTimedTextToPlayer( p, 0.0, 0.0, 15.0, " " )
		call DisplayTimedTextToPlayer( p, 0.0, 0.0, 15.0, " " )
	endfunction

	private function init takes nothing returns nothing
		local trigger t
		local integer i = 0
		set t = CreateTrigger()

		loop
			exitwhen i > 11
			call TriggerRegisterPlayerChatEvent(t, Player(i), "-ms", true)
			set i = i + 1
		endloop

		call TriggerAddAction(t,function MovespeedCommand)
	endfunction
endlibrary